<script>
	import { getExtensionByAppId, getUserTemplateConf } from '@/tools/request/api.js'
	import { mapActions } from 'vuex'
	export default {
		onLaunch: function() {
			// getExtConfig()： 确保获取完模板信息后再进行登录等操作
			// initApp()： 获取完模板后的初始化，包括登录，获取店铺信息等。
			this.getExtConfig().then( (res) => {
				if (res.code != 200) return;
				this.initApp(); 
				this.getBusinessInfo();
			})
			this.setNavi();
		},
		onShow: function() {
			
		},
		onHide: function() {
			
		},
		methods: {
			...mapActions('template_store', ['getExtConfig']),
			...mapActions('app_store', ['initApp']),
			...mapActions('business_store', ['getBusinessInfo']),
			pxToRpx (px) {
			  let screenWidth = wx.getSystemInfoSync().screenWidth;
			  let ratio = 750 / screenWidth;
			  return (px * ratio);
			},
			setNavi () {
				let capsulePosition = uni.getMenuButtonBoundingClientRect();
				let height = this.pxToRpx(capsulePosition.bottom);
				this.globalData.capsuleTop = this.pxToRpx(capsulePosition.top);
				this.globalData.capsuleHieght = this.pxToRpx(capsulePosition.height);
				this.globalData.capsuleBottom = height;
				this.globalData.headHeight = height + this.globalData.headPaddingBottom;
			}
		},
		globalData: {
			capsuleTop: 0,
			capsuleHieght: 0,
			capsuleBottom: 0,
			headPaddingBottom: 20,
			headHeight: 0,
		}
	}
</script>


<style lang="scss">
	@import "uview-ui/index.scss";
	@import './static/css/common.scss';
	@import './static/common/iconfont.css';
	
	page{
		background-color: $uni-bg-color-grey;
	}
</style>
